<%@ page contentType="text/html; charset=UTF-8" %>
<%@ page import="com.fick.hibernate.model.*,java.text.SimpleDateFormat"%>
<%@ page import="com.fick.hibernate.dao.*"%>
<%@page import="java.util.Date,com.fick.util.UpPic"%>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>河南省公安厅</title>
<link href="images/jiahao.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="js/check.js"></script>

	<%
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 
		//完成更新和保存
			String id=request.getParameter("id");
			int width = 300;
			if(request.getParameter("width")!=null && !request.getParameter("width").equals(""))
			    width=Integer.parseInt(request.getParameter("width"));
			int height = 400;
			if(request.getParameter("height")!=null && !request.getParameter("height").equals(""))
				height=Integer.parseInt(request.getParameter("height"));
			String title=request.getParameter("title");
			String content=request.getParameter("content");
			String bTime = request.getParameter("beginTime");
			String eTime = request.getParameter("endTime");
			System.out.println(bTime + "," + eTime);
			String url=request.getParameter("url");
			BaseHibernateDAO dao=new BaseHibernateDAO();
			PopWindow popWindow=null;
			if(id!=null && !id.equals(""))
			{
				popWindow=(PopWindow)dao.findBySql(PopWindow.class," where id="+request.getParameter("id")).get(0);
			}else
			{
				popWindow=new PopWindow();
			}
			popWindow.setWidth(width);
			popWindow.setHeight(height);
			popWindow.setContent(content);
			popWindow.setTitle(title);
			popWindow.setUrl(url);
			popWindow.setAddTime(new Date());
		    Date bdate = sdf.parse(bTime); 
			popWindow.setBeginTime(bdate);
			Date edate = sdf.parse(eTime);
			popWindow.setEndTime(edate);
			System.out.println(bdate.toString());
			dao.getSession().beginTransaction();
			dao.getSession().saveOrUpdate(popWindow);
			dao.getSession().beginTransaction().commit();
			dao.getSession().close();
			out.print("<script>window.location.href=\'popWindowList.jsp\'</script>");
	%>
